home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / dos / diverses / leda / incl / point_se.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-15  |  2.1 KB  |  98 lines

  1. /*******************************************************************************
  2. +
  3. +  LEDA  2.1.1                                                 11-15-1991
  4. +
  5. +
  6. +  point_set.h
  7. +
  8. +
  9. +  Copyright (c) 1991  by  Max-Planck-Institut fuer Informatik
  10. +  Im Stadtwald, 6600 Saarbruecken, FRG     
  11. +  All rights reserved.
  12. *******************************************************************************/
  13.  
  14.  
  15.  
  16.  
  17.  
  18. #ifndef POINTSETH
  19. #define POINTSETH
  20.  
  21. #include <LEDA/d2_dictionary.h>
  22. #include <LEDA/plane.h>
  23. #include <LEDA/delaunay_tree.h>
  24.  
  25.  
  26. typedef DT_item   ps_item;
  27.  
  28. typedef list(DT_item) list(ps_item);
  29.  
  30.  
  31. declare3(d2_dictionary,real,real,DT_item)
  32.  
  33.  
  34.  
  35. class Point_Set : public delaunay_tree {
  36.  
  37. d2_dictionary(real,real,DT_item) T;
  38.  
  39. public:
  40.  
  41. Point_Set()  {}
  42.  
  43. ps_item       lookup(point);
  44.  
  45. list(ps_item) range_search(real, real, real, real);
  46.  
  47. list(point)   all_points();
  48.  
  49. ps_item       insert(point p, void* i);
  50.  
  51. ps_item       nearest_neighbor(point p){ return delaunay_tree::neighbor(p); }
  52.  
  53. void          change_inf(ps_item it, void* i) { delaunay_tree::change_inf(it,i);}
  54.  
  55. void          del(point p)             {  delaunay_tree::del(p);
  56.                                           T.del(p.xcoord(),p.ycoord());
  57.                                         }
  58.  
  59. void          del_item(ps_item it) { del(key(it)); }
  60.  
  61. list(ps_item) all_items();
  62. list(ps_item) convex_hull();
  63.  
  64.  
  65. void          clear()   { T.clear(); delaunay_tree::clear();  }
  66. int           size()    { return T.size(); }
  67. bool          empty()   { return T.empty(); }
  68.  
  69.  
  70. };
  71.  
  72.  
  73. #define point_set(itype) name2(itype,point_set)
  74.  
  75.  
  76. #define point_setdeclare(itype)\
  77. \
  78. class point_set(itype) : public Point_Set {\
  79. \
  80. void clear_inf(ent& x) { Clear(*(itype*)&x);    }\
  81. void copy_inf(ent& x)  { Copy(*(itype*)&x); }\
  82. \
  83. public:\
  84. \
  85. void    change_inf(ps_item it, itype i) { Point_Set::change_inf(it,Ent(i));  }\
  86. itype   inf(ps_item it)                 { return itype(Point_Set::inf(it));  }\
  87. ps_item insert(point p, itype i)        { return Point_Set::insert(p,Ent(i));}\
  88. \
  89.  point_set(itype)()   {}\
  90. ~point_set(itype)()   { clear(); }\
  91. };
  92.  
  93. #define forall_ps_items(i,D) forall(i, (D.all_items()) )
  94.  
  95. #endif
  96.  
  97.